home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_02 / 9n02064a < prev    next >
Text File  |  1990-12-17  |  3KB  |  108 lines

  1. /*
  2.     Program relies on definitions of _MSC_VER or __TURBOC__
  3.     to account for compiler differences between Turbo C and
  4.     Microsoft C. These values are predefined.
  5. */
  6.  
  7. #if defined( _MSC_VER )
  8.  
  9. #include <malloc.h>
  10. #include <direct.h>
  11.  
  12.         /* Turbo */             /* Microsoft */
  13. /* translate structure name and members */
  14. #define ffblk                   find_t
  15. #define ff_reserved             reserved
  16. #define ff_attrib               attrib
  17. #define ff_ftime                wr_time
  18. #define ff_fdate                wr_date
  19. #define ff_fsize                size
  20. #define ff_name                 name
  21. /* translate attribute mask defines */
  22. #define FA_RDONLY               _A_RDONLY
  23. #define FA_HIDDEN               _A_HIDDEN
  24. #define FA_SYSTEM               _A_SYSTEM
  25. #define FA_LABEL                _A_VOLID
  26. #define FA_DIREC                _A_SUBDIR
  27. #define FA_ARCH                 _A_ARCH
  28. /*
  29.    use macros to substitute functions and
  30.    swap argument order
  31. */
  32. #define findfirst( a , b , c )  _dos_findfirst((a),(c),(b))
  33. #define findnext( a )           _dos_findnext((a))
  34.  
  35. /* end of _MSC_VER */
  36. #elif defined( __TURBOC__ )
  37.  
  38. #include <dir.h>
  39. #include <alloc.h>
  40.  
  41. #endif /* __TURBOC__ */
  42.  
  43. #include <dos.h>
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #include <time.h>
  48.  
  49.  
  50. /* defines */
  51. #define VERSION    "NO_DUP Ver 1.0, Jerzy Tomasik (c) 1990"
  52. #define ALL_FILES  0xFFFF      /* flag for _dos_find??? */
  53. #define MAX_LINE   80
  54. #define MAX_PATH   80
  55. #define MAX_FLEN   13
  56. #define MAX_FILES  15000
  57. #define SEPARATOR  "************\n"
  58.  
  59. /* data definitions and declarations */
  60.  
  61. typedef enum { False, True } Flag;
  62.  
  63. /*
  64.     DirEntry structure holds data for all files
  65. */
  66. typedef struct DirEntry
  67.     {
  68.     char *path;
  69.     char name[13];
  70.     char attrib;
  71.     unsigned time;
  72.     unsigned date;
  73.     long size;
  74.     Flag dir_processed;
  75.     } DirEntry;
  76.  
  77. /*
  78.     DirList structure holds the listing of all
  79.     subdirectories on a disk
  80. */
  81. typedef struct DirList
  82.     {
  83.     char pathname[MAX_PATH];
  84.     Flag dir_processed;
  85.     struct DirList *prev;
  86.     struct DirList *next;
  87.     } DirList;
  88.  
  89. typedef struct
  90.     {
  91.     Flag dir;
  92.     Flag file;
  93.     unsigned int  file_count;
  94.     unsigned long total_file_size;
  95.     } GlobalOpt;
  96.  
  97. typedef char *PtrList;
  98.  
  99. /* function prototypes */
  100.  
  101. DirEntry *get_direntry     ( char * );
  102. DirList  *make_path        ( char *, char *, DirList * );
  103. DirList  *get_path         ( DirList * );
  104. int       name_comp        ( const void *, const void * );
  105. char     *datestr          ( unsigned d, char *buf );
  106. char     *timestr          ( unsigned t, char *buf );
  107. void      fprint_direntry  ( FILE *, DirEntry * );
  108.